﻿package mortal.game.view.task.guild
{
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import flash.geom.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class GuildTaskItem extends GSprite
    {
        private var _bg:GImageBitmap;
        private var _txtGX:GTextFiled;
        private var _txtJY:GTextFiled;
        private var _bmpPZ:GBitmap;
        private var _bmpSelected:GBitmap;
        private var _pz:int = -1;
        private var _loaded:Boolean = false;
        private var _pzPre:String = "GuildTask_PZ";

        public function GuildTaskItem()
        {
            return;
        }// end function

        public function get pzPre() : String
        {
            return this._pzPre;
        }// end function

        public function set pzPre(param1:String) : void
        {
            this._pzPre = param1;
            this.updatePZ();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bmpSelected = UIFactory.gBitmap(null, -10, -78);
            this._bg = UIFactory.gImageBitmap(null);
            var _loc_1:* = GlobalStyle.textFormatPutong;
            _loc_1.size = 13;
            _loc_1.color = 15057665;
            this._txtGX = UIFactory.gTextField("", 47, 0, 200, 20, this, _loc_1);
            this._txtJY = UIFactory.gTextField("", 47, 18, 200, 20, this, _loc_1.clone());
            this._bmpPZ = UIFactory.gBitmap(null, 0, 37, this);
            LoaderHelp.addResCallBack(ResFileConst.taskGuild, this.resGotHandler);
            return;
        }// end function

        public function updateTask(param1:int, param2:int, param3:int, param4:String = "guildTaskForFly_guild") : void
        {
            this._txtGX.text = param3.toString();
            this._txtJY.text = param2.toString();
            this._pz = param1;
            this.updatePZ();
            this._bg.imgUrl = param4 + param1;
            return;
        }// end function

        public function setSelected(param1:Boolean) : void
        {
            if (param1)
            {
                this.addChildAt(this._bmpSelected, 0);
                EffectManager.glowFilterReg(this._bmpSelected);
            }
            else
            {
                DisplayUtil.removeMe(this._bmpSelected);
                EffectManager.glowFilterUnReg(this._bmpSelected);
            }
            return;
        }// end function

        private function resGotHandler() : void
        {
            this._loaded = true;
            if (isDisposed)
            {
                return;
            }
            this.updatePZ();
            this._bmpSelected.bitmapData = GlobalClass.getBitmapData(ImagesConst.GuildTask_Selected);
            return;
        }// end function

        private function updatePZ() : void
        {
            if (!this._loaded)
            {
                return;
            }
            if (this._pz == -1)
            {
                return;
            }
            this._bmpPZ.bitmapData = GlobalClass.getBitmapData(this._pzPre + this._pz.toString());
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._pz = -1;
            if (this._bmpSelected != null)
            {
                this._bmpSelected.dispose(param1);
                this._bmpSelected = null;
            }
            this._txtGX.dispose(param1);
            this._txtGX = null;
            this._txtJY.dispose(param1);
            this._txtJY = null;
            this._bmpPZ.dispose(param1);
            this._bmpPZ = null;
            this._bg.dispose(param1);
            this._bg = null;
            return;
        }// end function

        public function flyToPoint(param1:Point) : void
        {
            if (isDisposed)
            {
                return;
            }
            if (this._bg == null || this._bg.bitmapData == null || this._bg.bitmapData.width < 10)
            {
                return;
            }
            FlyToNavbarTool.flyToAnyPoint(this._bg.bitmapData, this.localToGlobal(GameConst.yellowPoint), param1, null, 0, 0, false, 0.4, 0.4);
            return;
        }// end function

    }
}
